
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class banner_model extends MY_Model
{

	 public function getBannerList()
    {
        $sql = "SELECT * FROM ym_banner   ORDER BY  sort_order desc ,add_time desc";
        $query = $this->db->query($sql);
        return $query->result_array();
    }

     //编辑
    public function editAd($id,$data = array()){
        if($id){
            $this->db->where("id",$id);
            $res = $this->db->update("ym_banner",$data);
        }else{
            $res = $this->db->insert("ym_banner",$data);
        }
        return $res;
    }

    public function delAd($id){
        $this->db->where("id",$id);
      
        $res = $this->db->delete("ym_banner");
        return $res;
    }

     //根据id获取广告信息
    public function getAdInfobyID($id){
        $this->db->where("id",$id);
        $query = $this->db->get("ym_banner");
        return $query->row_array();
    }

}


